home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
PROGRAM
/
CUJ9104.ARJ
/
9N04120A
< prev
next >
Wrap
Text File
|
1990-12-31
|
1KB
|
38 lines
#include <stdio.h>
FILE *ofp;
void main( void ) {
double big, small;
float fbig, fsmall;
int flag[4], power;
ofp = fopen( "roundoff.out", "w" );
big = small = 1.0;
fbig = (float)big;
for( power = 1; power <= 50; power++ ) {
small *= 0.1;
fsmall = (float)small;
flag[0] = flag[1] = flag[2] = flag[3] = 1;
if( big+small == big )
flag[0] = 0;
if( (big+small) == big )
flag[1] = 0;
if( fbig+fsmall == fbig )
flag[2] = 0;
if( (fbig+fsmall) == fbig )
flag[3] = 0;
printf( "Power = %2d, Big+Small = %e, Flags = %d %d %d %d\n",
power, big+small, flag[0], flag[1], flag[2], flag[3] );
fprintf( ofp, "Power = %2d, Big+Small = %e, Flags = %d %d %d %d\n",
power, big+small, flag[0], flag[1], flag[2], flag[3] );
}
}